<template>
  <el-form :model="formData" label-width="120px" ref="form" v-loading="loading" class="pr-4">
    <el-form-item label="地址" prop="url">
  <el-input v-model="formData.url" name="url" clearable />
</el-form-item>
<el-form-item label="原名" prop="file_name">
  <el-input v-model="formData.file_name" name="file_name" clearable />
</el-form-item>
<el-form-item label="后缀" prop="file_ext">
  <el-input v-model="formData.file_ext" name="file_ext" clearable />
</el-form-item>
<el-form-item label="类型" prop="file_type">
  <el-input v-model="formData.file_type" name="file_type" clearable />
</el-form-item>
<el-form-item label="大小" prop="file_size">
  <el-input v-model="formData.file_size" name="file_size" clearable />
</el-form-item>
<el-form-item label="路径" prop="file_path">
  <el-input v-model="formData.file_path" name="file_path" clearable />
</el-form-item>
    <div class="flex justify-end">
      <el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import { useCreate } from '@/composables/curd/useCreate'
import { useShow } from '@/composables/curd/useShow'
import { onMounted } from 'vue'

const props = defineProps({
  primary: [String, Number],
  api: String,
})

const { formData, form, loading, submitForm, close } = useCreate(props.api, props.primary)

if (props.primary) {
  useShow(props.api, props.primary, formData)
}

const emit = defineEmits(['close'])
onMounted(() => {
  close(() => emit('close'))
})
</script>
